package com.wx.wugl.controller;


import com.wx.wugl.common.CommonResult;
import com.wx.wugl.entity.EmArchivesEntity;
import com.wx.wugl.service.EmArchivesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zhang
 * @since 2021-05-31
 */
@RestController
@RequestMapping("/archives")
public class EmArchivesController {

    @Autowired
    private EmArchivesService emArchivesService;

    @GetMapping("/findAll")
    public CommonResult findAll(EmArchivesEntity emArchivesEntity){
        return CommonResult.success(emArchivesService.findAll(emArchivesEntity));
    }

    @GetMapping("/getById")
    public CommonResult getById(String id){
        EmArchivesEntity emArchivesEntity = emArchivesService.findById(id);
        return CommonResult.success(emArchivesEntity);
    }

    @PostMapping("/add")
    public CommonResult addArchives(EmArchivesEntity emArchivesEntity) {
        int res = emArchivesService.add(emArchivesEntity);
        return CommonResult.success(res);
    }

    @PostMapping("/update")
    public CommonResult updateArchives(EmArchivesEntity emArchivesEntity) {
        int res = emArchivesService.update(emArchivesEntity);
        return CommonResult.success(res);
    }

    @PostMapping("/delete")
    public CommonResult deleteArchives(String id) {
        int res = emArchivesService.deleteById(id);
        return CommonResult.success(res);
    }

}
